home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / libs / winlib-0.0 / winlib-0 / win / Configure < prev    next >
Encoding:
Text File  |  1995-12-25  |  4.1 KB  |  167 lines

  1. #!/usr/bin/perl
  2. #
  3. # Perl configuration script for WinLIB
  4. # by Ken Hollis
  5. #
  6. # Version 1.0.0
  7.  
  8. $> && die "\nYou must be root or superuser to build the WinLIB library.\n\n";
  9. $| = 1;
  10.  
  11. sub ask {
  12.     $question = "";
  13.     $default = "";
  14.     $prompt = "";
  15.  
  16.     $question = $_[0];
  17.     $default = $_[1];
  18.     $prompt = $_[2];
  19.  
  20.     print "${question} ${prompt} ";
  21.  
  22.     $answer = <stdin>;
  23.     chop($answer);
  24.  
  25.     $answer =~ tr/a-z/A-Z/;
  26.  
  27.     if (($answer eq "") || ($answer eq $default)) {
  28.     return 1;
  29.     } else {
  30.     return 0;
  31.     }
  32. }
  33.  
  34. sub find {
  35.     open(FI, "which $_[0]|");
  36.     while(<FI>) {
  37.     chop;
  38.     if (/no/) {
  39.         return 0;
  40.     } else {
  41.         return $_;
  42.     }
  43.     }
  44.     close(FI);
  45. }
  46.  
  47. sub do_stuff {
  48.     system("clear");
  49.     print <<"EOT";
  50. * Welcome to WinLIB 0.0.3 installation script.
  51. * Checking some stuff...
  52.  
  53. EOT
  54.     $system = `uname`;
  55.     $os_ver = `uname -r`;
  56.  
  57.     chop($system);
  58.     chop($os_ver);
  59.  
  60.     if ($system eq "Linux") {
  61.     print "* Linux version $os_ver.\n";
  62.     } else {
  63.     print <<"EOT";
  64. Sorry, you're not running Linux.  This library requires Linux in order to 
  65. compile correctly.  Ports may be made to your operating system, but 
  66. currently, the library only supports Linux.  Sorry!
  67. EOT
  68.     exit;
  69.     }
  70.  
  71.     print "* One moment...";
  72.     `cd config ; make -s`;
  73.     print "\r               \r";
  74.  
  75.     open(VER, "cd config ; check|");
  76.     while(<VER>) {
  77.     chop;
  78.     ($gpmver,$ncursesver) = split(/:/);
  79.     }
  80.     close(VER);
  81.  
  82.     print "* GPM Version $gpmver installed.\n";
  83.     print "* NCURSES Version $ncursesver installed.\n";
  84.     print "\n";
  85.  
  86.     $elf = &ask("Create ELF shared library?", "Y", "[Y/n]");
  87.     $aout = &ask("Create A.OUT static library?", "Y", "[Y/n]");
  88.     $dg = &ask("Enable -g option on libraries?  (Makes larger libs)?", "N", "[y/N]");
  89.     $dg = ($dg == 1) ? "" : "-g ";
  90.  
  91.     die "\nYou need to create at least one library!\n\n" if (($elf == 0) && ($aout == 0));
  92.  
  93.     print "\n";
  94.  
  95.     $debug = &ask("Enable debugging?", "Y", "[Y/n]");
  96.     $show_coord = &ask("Enable mouse coordinate info?", "Y", "[Y/n]");
  97.     $color = &ask("Enable color support?", "Y", "[Y/n]");
  98.     $sound = &ask("Enable sound support?", "Y", "[Y/n]");
  99.  
  100.     if ($sound == 1) {
  101.     $aud = &ask("Enable use of \"/dev/audio\" device?", "Y", "[Y/n]");
  102.     $audio = ($aud == 1) ? "#define\tUSE_DEV_AUDIO" : "#undef\tUSE_DEV_AUDIO";
  103.     $soundprog = &find("play");
  104.     if ($soundprog ne "") {
  105.         $sf = &ask("Found \"play\" in \"$soundprog\" for .WAV files.  Use it?", "Y", "[Y/n]");
  106.         if ($sf == 1) {
  107.         $sfp = ($sf == 1) ? "#define\tWAVFILE\t\t\"$soundprog\"" : "#undef\tWAVFILE";
  108.         }
  109.     } else {
  110.         print "\n* No .WAV file player found.  .WAV file support disabled.\n";
  111.     }
  112.     }
  113.  
  114.     print "\nWhat's the IP address of your sound server? ";
  115.     $ipaddr = <stdin>;
  116.     chop($ipaddr);
  117.  
  118.     $debug = ($debug == 1) ? "#define\tDEBUG" : "#undef\tDEBUG";
  119.     $coord = ($show_coord == 1) ? "#define\tMOUSE_COORD" : "#undef\tMOUSE_COORD";
  120.     $color = ($color == 1) ? "#define\tCOLOR_SUPPORT" : "#undef\tCOLOR_SUPPORT";
  121.     $sound = ($sound == 1) ? "#define\tSOUND_SUPPORT" : "#undef\tSOUND_SUPPORT";
  122.     $soundip = "#define\tSOUND_ADDRESS\t\"$ipaddr\"";
  123.  
  124.     open(OUTF, ">Makefile.defs") || die "Makefile.defs: $!\n";
  125.     print OUTF "# This file is automatically generated by the Configuration\n";
  126.     print OUTF "# program.  Do not change this file!\n\n";
  127.     print OUTF "DONE_CONFIG= 1\n";
  128.     print OUTF "AOUT_LIB= $aout\n";
  129.     print OUTF "ELF_LIB= $elf\n";
  130.     close(OUTF);
  131.  
  132.     open(INF, "config.h.in") || die "(Open) config.h.in: $!\n";
  133.     open(OUTF, ">config.h") || die "(Write) config.h: $!\n";
  134.     while(<INF>) {
  135.     s/\$0/$debug/;
  136.     s/\$1/$coord/;
  137.     s/\$2/$color/;
  138.     s/\$3/$sound/;
  139.     s/\$4/$sfp/;
  140.     s/\$5/$audio/;
  141.     s/\$6/$soundip/;
  142.     print OUTF $_;
  143.     }
  144.     close(OUTF);
  145.     close(INF);
  146.  
  147.     open(INF, "Makefile.in") || die "Makefile.in: $!\n";
  148.     open(OUTF, ">Makefile") || die "Makefile: $!\n";
  149.     while(<INF>) {
  150.     s/\$0/$dg/;
  151.     print OUTF $_;
  152.     }
  153.     close(OUTF);
  154.     close(INF);
  155.  
  156.     print <<"EOT";
  157.  
  158. * Great!  We're done.
  159. * You should now be able to type \"make\" and everything will take place
  160.   according to plan.
  161. * If you are skeptical, please edit \"config.h\" before typing \"make\".
  162.  
  163. EOT
  164. }
  165.  
  166. &do_stuff;
  167.